<!--执行详情-普通-->
<template>
  <div class="bg" @rightBtn="rightBtn">
    <scroller class="scroller">
      <div class="wrapper bg1" v-if="menus">
        
        <!--跟单-基础信息-->
        <div class="column" v-if="detailMap.isFollow">
          <div class="row acenter">
            <div class="row aend">
              <text class="font32 text1">{{detailMap.followName ? T(detailMap.followName) : T(detailMap.strategyName)}}</text>
              <text class="font24 text3" v-if="detailMap.strategyCode">{{'  '+detailMap.strategyCode}}</text>
            </div>
            <div class="all"></div>
            <text class="font28 text1">{{detailMap.commission+'VTN/日'}}</text>
          </div>

          <div class="height20"></div>
          <text class="font24 text3">{{parseTime1(detailMap.startTime)+'-('+getExecuteTime(detailMap.startTime)+')'}}</text>
          
          <div class="line bg3"></div>

          <div class="row acenter" @click="userClick(detailMap.followUserId)">
          <LImage class="image" :src="detailMap.avatar ? detailMap.avatar : Config.img('view_image_portrait_normal.png')"></LImage>  
          <text class="font32 text1">{{detailMap.nickName}}</text>
          <div class="all"></div>
          <LImage class="arrow" :src="Config.img('strategy_arrow.png')"></LImage>
          </div>
        </div>
        
        <!--其他-基础信息-->
        <div class="column" v-else>

          <div class="row acenter">
            <div class="row aend">
              <text class="font32 text1">{{detailMap.followName ? T(detailMap.followName) : T(detailMap.strategyName)}}</text>
              <text class="font24 text3" v-if="detailMap.strategyCode">{{'  '+detailMap.strategyCode}}</text>
            </div>
  
            <div class="all"></div>

            <div class="row acenter"  v-if="detailMap.states=='EXECUTE' 
                                          && configMap.signal 
                                          && configMap.signal.openSignal 
                                          && detailMap.signalStates==0">
              <LImage class='msg' :src="Config.img('dengdai.png')"></LImage>
              <text class="font24 udRed-t1">{{T('等待信号触发')}}</text>
            </div>
            <text v-else :class="['font28', (detailMap.states == 'EXECUTE' ?  'main-t1' : 'text3')]">{{getStateStr(detailMap.states)}}</text>
          </div>

          <div class="height20"></div>
          <div class="row aend">
            <text class="font24 text3">{{parseTime1(detailMap.startTime)+'-('+getExecuteTime(detailMap.startTime)+')'}}</text>
            <div class="all"></div>
            <text class="font28 text3" v-if="detailMap.isOpenFollow==true">{{T("开放跟单")}}</text>
          </div>
        </div>
        
        <!--投入数据-->
        <div class="line bg3"></div>
        <div class="column">
          <text class="font24 text2 " >{{getExchangeName()}}</text>

          <div class="height20"></div>
          <div class="row">
            <text class="font24 text3">{{T('总投入')+'('+pair.investCoin+')'}}</text>
            <div class="all"></div>
            <text class="font24 text3">{{T('总收益')+'('+pair.investCoin+')'}}</text>
          </div>

          <div class="height20"></div>
          <div class="row">
            <text class="font32 text2">{{pair.investCoinnNum}}</text>
            <div class="all"></div>
            <text :class="['font32', Config.upDownFont(redisMap.realEarnings)]">{{redisMap.realEarnings + '(' +math.addJia(redisMap.realEarningsRate) + '%)'}}</text>
          </div>
        </div>
        
        <!--收益信息-->
        <div class="line bg3"></div>
        <div class="row all">
          <div class="column all">
            <text class="font24 text3">{{T('实现盈亏')+'('+pair.investCoin+')'}}</text>
            <text :class="['font24', Config.upDownFont(redisMap.earnings)]">{{math.addJia(redisMap.earnings)}}</text>
            <text :class="['font24', Config.upDownFont(redisMap.earnings)]">{{math.addJia(redisMap.earningsRate)+'%'}}</text>
          </div>
          <div class="column all">
            <text class="font24 text3">{{T('浮动盈亏')+'('+pair.investCoin+')'}}</text>
            <text :class="['font24', Config.upDownFont(redisMap.floatEarnings)]">{{math.addJia(redisMap.floatEarnings)}}</text>
            <text :class="['font24', Config.upDownFont(redisMap.floatEarnings)]">{{math.addJia(redisMap.floatEarningsRate)+'%'}}</text>
          </div>
          <div class="column all aend">
            <text class="font24 text3">{{T('实现年化')+'/'+T('总年化')}}</text>
            <text :class="['font24', Config.upDownFont(detailMap.yearIncome)]">{{math.addJia(detailMap.yearIncome)+'%'}}</text>
            <text :class="['font24', Config.upDownFont(detailMap.realYearIncome)]">{{math.addJia(detailMap.realYearIncome)+'%'}}</text>
          </div>
        </div>

        <!--交易数-->
        <div class="line bg3"></div>
        <div class="row  all">
          <div class="column all">
            <text class="font24 text3">{{T('累计买入')}}</text>
            <text class="font24 text2">{{redisMap.finishBuyCount}}</text>
          </div>
          <div class="column all">
            <text class="font24 text3">{{T('累计卖出')}}</text>
            <text class="font24 text2">{{redisMap.finishSellCount}}</text>
          </div>
          <div class="column all aend">
            <text class="font24 text3">{{T('交易数')}}</text>
            <text class="font24 text2">{{redisMap.finishBuySellCount}}</text>
          </div>
        </div>

        <!--收益走势图-->
        <div class="line bg3"></div>
        <div class="column">
          <div class="row acenter">
            <text class="font28 text1">{{T('收益分析')}}</text>
            <div class="all"></div>
            <div class="line-chart-color main1"></div>
            <text class="font24 text2">{{T("总收益率")}}</text>
          </div>
          <WeexLineChart class="line-chart" :data="lineChartData"></WeexLineChart>
        </div>

        <!--止盈止损-->
        <div class="line bg3"></div>
        <div class="column">
          <text class="font28 text1">{{T('止盈止损')}}</text>
          <div class="height20"></div>
          <div class="row all">

            <div class="column all">
              <text class="font24 text3">{{T('策略止盈率')}}</text>
              <text class="font24 text2">{{stopProfit}}</text>
            </div>

            <div class="column all">
              <text class="font24 text3">{{T('策略止损率')}}</text>
              <text class="font24 text2">{{stopLoss}}</text>
            </div>

            <div class="column all aend">
              <text class="font24 text3">{{T('自动终止时间')}}</text>
              <text class="font24 text2">{{stopTime}}</text>
            </div>
          </div>
        </div>

        <!--持仓-->
        <div class="line bg3"></div>
        <div class="column">
          <text class="font28 text1">{{T('持仓')}}</text>
          <div class="height40"></div>
          <div class="row jbetween" v-if="redisMap.inverstCoin == redisMap.baseCoin">
            <div class="column">
              <text class="font20 text3">{{T('币种')}}</text>
              <div class="height20"></div>
              <text class="font20 text2">{{redisMap.baseCoin}}</text>
              <div class="height20"></div>
              <text class="font20 text2">{{redisMap.counterCoin}}</text>
            </div> 

            <div class="column">
              <text class="font20 text3">{{T('数量')}}</text>
              <div class="height20"></div>
              <text class="font20 text2">{{redisMap.baseCoinTotal}}</text>
              <div class="height20"></div>
              <text class="font20 text2">{{redisMap.counterCoinTotal}}</text>
            </div>

            <div class="column">
              <text class="font20 text3">{{T('浮动盈亏')+'('+redisMap.inverstCoin+')'}}</text>
              <div class="height20"></div>
              <text class="font20 text2">{{'--'}}</text>
              <div class="height20"></div>
              <text :class="['floatText', 'font20', Config.upDownFont(redisMap.floatEarnings)]">{{redisMap.floatEarnings}}</text>
            </div>

            <div class="column aend">
              <text class="font20 text3">{{T('开仓均价')+'('+redisMap.baseCoin+')'}}</text>
              <div class="height20"></div>
              <text class="font20 text2">{{'--'}}</text>
              <div class="height20"></div>
              <text class="floatText font20 text2">{{math.getNumber(redisMap.costPrice) == 0 ? '--' : redisMap.costPrice}}</text>
            </div>
          </div>
          <div class="row jbetween" v-else>
            <div class="column">
              <text class="font20 text3">{{T('币种')}}</text>
              <div class="height20"></div>
              <text class="font20 text2">{{redisMap.counterCoin}}</text>
              <div class="height20"></div>
              <text class="font20 text2">{{redisMap.baseCoin}}</text>
            </div> 

            <div class="column">
              <text class="font20 text3">{{T('数量')}}</text>
              <div class="height20"></div>
              <text class="font20 text2">{{redisMap.counterCoinTotal}}</text>
              <div class="height20"></div>
              <text class="font20 text2">{{redisMap.baseCoinTotal}}</text>
            </div>

            <div class="column">
              <text class="font20 text3">{{T('浮动盈亏')+'('+redisMap.inverstCoin+')'}}</text>
              <div class="height20"></div>
              <text class="font20 text2">{{'--'}}</text>
              <div class="height20"></div>
              <text :class="['floatText', 'font20', Config.upDownFont(redisMap.floatEarnings)]">{{redisMap.floatEarnings}}</text>
            </div>

            <div class="column aend">
              <text class="font20 text3">{{T('开仓均价')+'('+redisMap.baseCoin+')'}}</text>
              <div class="height20"></div>
              <text class="floatText font20 text2">{{math.getNumber(redisMap.costPrice) == 0 ? '--' : redisMap.costPrice}}</text>
              <div class="height20"></div>
              <text class="font20 text2">{{'--'}}</text>
            </div>
          </div>
        </div>

        <!--当前委托-->
        <div class="height40"></div>
        <div class="column">
          <text class="font28 text1">{{T('当前委托')+'('+(buyList.length+sellList.length)+')'}}</text>
          <WeexBuySell class="buySell" :buy="buyPrice1" :sell="sellPrice1" :pair="pairStr"></WeexBuySell>
          
          <div class="line2 bg3"></div>
          <div class="row jbetween">
            <div class="column">
              <text class="font20 text3">{{T('买入数量')+'('+buyList.length+')'}}</text>
              <text class="font20 text2 text68" v-for="(item, index) in buyList" v-bind:key="index">{{item.amount}}</text>
            </div>
            
            <div class="column">
              <text class="font20 text3">{{T('委托价格')+'('+this.redisMap.baseCoin+')'}}</text>
              <text :class="['font20', 'text68', Config.upDownFont(1)]" v-for="(item, index) in buyList" v-bind:key="index">{{item.price}}</text>
            </div>
            
            <div class="column">
              <text class="font20 text3">{{T('卖出数量')+'('+sellList.length+')'}}</text>
              <text class="font20 text2 text68" v-for="(item, index) in sellList" v-bind:key="index">{{item.amount}}</text>
            </div>
            
            <div class="column aend">
              <text class="font20 text3">{{T('委托价格')+'('+this.redisMap.baseCoin+')'}}</text>
              <text :class="['font20', 'text68', Config.upDownFont(-1)]" v-for="(item, index) in sellList" v-bind:key="index">{{item.price}}</text>
            </div>
          </div>
        </div>
      </div>
    </scroller>
    
    <!-- 菜单 -->
    <div class="menu" v-if="showMenu" @click="hideClick">
      <div class="meun-content bg3">
        <text class="font24 text2 meun-text" v-for="(item, index) in menus" v-bind:key="index" @click="menuClick(item)">{{T(item)}}</text>
      </div>
    </div>
  </div>
</template>

<script>
import navigator from "@/_js/navigator";
import modal from "@/_js/modal";
import math from "@/_js/math";
import debug from "@/_js/debug";
import amStrategy2 from "@/strategy/amStrategy2";
import Config from "@/_js/config";
import broadcast from "@/_js/broadcast";

const weexFunction = weex.requireModule("WeexFunction");
import weexHttp from "@/_js/https"; ;

import I18N from "@/_i18n/i18n";
var T = I18N.t;
weexFunction.setTitle(T("执行详情"));
weexFunction.setRightBtn(T("功能"));

//执行详情
export default {
  
  data() {
    return {
      T: T,
      Config:Config,
      math:math,
      showMenu:false, //显示功能
      menus:undefined, //菜单

      executeId: "", //执行id

      detailMap: undefined, //执行信息
      redisMap: undefined, //数据库信息
      configMap: undefined, //执行配置
      followMap: undefined, //跟单配置
      followMimic: false, //turn 模拟盘开放跟单
      pair:undefined, //交易对
      lineChartData:undefined, //收益走势

      stopProfit: '', //止盈
      stopLoss: '', //止损
      stopTime: '', //自动终止时间

      buyList: [], //委托买单列表
      sellList: [], //委托卖单列表

      buyPrice1:undefined, //买1价格
      sellPrice1:undefined, //卖1价格
      pairStr:undefined, //交易对字符串
    };
  },

  mounted() {

    Config.init(()=>{
      this.executeId = navigator.getParam("executeId");
      this.httpExecuteDetail();
    },[Config.OPT_UP_DOWN]);

    //刷新订阅
    broadcast.subscribe('RunInfo', broadcast.EXECUTE_UPDATE, ()=>{
      this.httpExecuteDetail();
    });
  },

  methods: {

    //初始菜单
    initMenu(){

      if (this.detailMap.isFollow){
        this.menus = ['消息', '加仓', '终止', '成交记录'];
        return;
      }
      
      var menus;
      if (this.detailMap.states == "SUSPEND") { //暂停状态
        menus = ['消息', '参数', '重启', '加仓', '终止'];
      } else { //执行中
        menus = ['消息', '参数', '暂停', '加仓', '终止'];
      }
      
      if(this.detailMap.strategyName=='DCA智能策略') {
        menus.push('手动开仓');
        menus.push('一键平仓');
      }

      //海浪网格，新增网格列表
      if (this.detailMap.strategyId == 'WL202007311426363421x') {
        menus.push('网格列表');
      }

      menus.push('成交记录');

      this.menus = menus;
    },

    /*************************************************通信触发*/
    //右按钮触发
    rightBtn() {
      this.menus&&(this.showMenu = !this.showMenu);
    },

    /********************************** HTTP*/
    //http执行详情
    httpExecuteDetail() {
      if (this.executeId == '') {
        return;
      }

      this.detailMap = undefined;
      var param = { executeId: this.executeId};
      weexHttp.post("strategyV3/executeDetail",param,true,(data) => {

          if (data.status == 200) {

            data = data.data;
            this.redisMap = data.redisMap;
            this.followMap = data.followMap;
            this.detailMap = data.executeDetail;
            this.configMap = data.executeDetail.config;
            this.followMimic = data.followMimic;
            
            //收益曲线
            var realEarningsLine = this.redisMap.realEarningsLine;
            this.lineChartData = realEarningsLine ? realEarningsLine.items : [];

            //复制交易对-避免截取总投入时，加仓、减仓一次问题。
            this.pair = JSON.parse(JSON.stringify(this.configMap.tradePairs[0]));
            var xiaoshu = math.getCoin(this.pair.investCoin);

            //总投入
            this.pair.investCoinnNum = math.xiaoshu(this.pair.investCoinnNum, xiaoshu, 2);

            //总盈亏
            this.redisMap.realEarnings = math.xiaoshu(this.redisMap.realEarnings, xiaoshu, 2);
            this.redisMap.realEarningsRate = math.xiaoshu(this.redisMap.realEarningsRate, 2, 2);

            //浮动盈亏
            this.redisMap.floatEarnings = math.xiaoshu(this.redisMap.floatEarnings, xiaoshu, 2);
            this.redisMap.floatEarningsRate = math.xiaoshu(this.redisMap.floatEarningsRate, 2, 2);

            //实现盈亏
            this.redisMap.earnings = math.xiaoshu(this.redisMap.earnings, xiaoshu, 2);
            this.redisMap.earningsRate = math.xiaoshu(this.redisMap.earningsRate, 2, 2);

            //实现年化
            this.detailMap.yearIncome = math.xiaoshu(this.detailMap.yearIncome, 2, 2);
            this.detailMap.realYearIncome = math.xiaoshu(this.detailMap.realYearIncome, 2, 2);

            //交易数量
            this.redisMap.finishBuyCount = this.redisMap.finishBuyCount ? this.redisMap.finishBuyCount : '0';
            this.redisMap.finishSellCount = this.redisMap.finishSellCount ? this.redisMap.finishSellCount : '0';
            this.redisMap.finishBuySellCount = math.jia(this.redisMap.finishBuyCount, this.redisMap.finishSellCount);

            //止盈止损
            this.configMap.stopProfit = this.configMap.stopProfit?this.configMap.stopProfit:'';
            this.stopProfit = this.configMap.stopProfit.length > 0 ? (math.cheng(this.configMap.stopProfit, '100') + '%') : '--';
            this.configMap.stopLoss = this.configMap.stopLoss?this.configMap.stopLoss:'';
            this.stopLoss = this.configMap.stopLoss.length > 0 ? (math.cheng(this.configMap.stopLoss, '-100') + '%') : '--';
            this.configMap.stopTime = this.configMap.stopTime?this.configMap.stopTime:'';
            this.stopTime = this.configMap.stopTime.length > 0 ? this.parseTime1(math.getNumber(this.configMap.stopTime)) : '--';

            //交易币、本币、投资币
            this.redisMap.inverstCoin = this.redisMap.inverstCoin.toUpperCase();
            this.redisMap.counterCoin = this.redisMap.counterCoin.toUpperCase();
            this.redisMap.baseCoin = this.redisMap.baseCoin.toUpperCase();

            //交易币、本币 数量/冻结率
            this.redisMap.baseCoinTotal = math.xiaoshu(this.redisMap.baseCoinTotal, math.getCoin(this.redisMap.baseCoin));
            this.redisMap.counterCoinTotal = math.xiaoshu(this.redisMap.counterCoinTotal, math.getCoin(this.redisMap.counterCoin));
            var baseCoinFreezRate = math.chu(this.redisMap.baseCoinFreez, this.redisMap.baseCoinTotal, 4, 2);
            var counterCoinFreezRate = math.chu(this.redisMap.counterCoinFreez, this.redisMap.counterCoinTotal, 4, 2);
            baseCoinFreezRate = math.getNumber(baseCoinFreezRate) > 1 ? '1' : baseCoinFreezRate;
            counterCoinFreezRate = math.getNumber(counterCoinFreezRate) > 1 ? '1' : counterCoinFreezRate;
            this.redisMap.baseCoinFreezRate = math.cheng(baseCoinFreezRate, '100', 2, 2);
            this.redisMap.counterCoinFreezRate = math.cheng(counterCoinFreezRate, '100', 2, 2);

            //持仓   
            this.redisMap.costPrice =  math.xiaoshu(this.redisMap.costPrice, this.pair.baseCoinDecimal, 2);
            
            //浮动盈亏
            // var xiaoshu = math.getCoin(this.redisMap.inverstCoin);
            // var profitLoss;
            // if (this.redisMap.inverstCoin == this.redisMap.baseCoin) {
            //   var price = math.jian(this.redisMap.curPrice, this.redisMap.costPrice);
            //   profitLoss = math.cheng(price, this.redisMap.counterCoinTotal, xiaoshu, 2);
            // } else {
            //   var cost = math.chu(this.redisMap.baseCoinTotal, this.redisMap.costPrice); //成本价
            //   var cur = math.chu(this.redisMap.baseCoinTotal, this.redisMap.curPrice); //当前价
            //   profitLoss = math.jian(cost, cur, xiaoshu, 2);
            // }
            // this.redisMap.profitLoss = profitLoss;

            //浮动盈亏率
            // var profitLossRate;
            // if (this.redisMap.inverstCoin == this.redisMap.baseCoin) {
            //   var price = math.jian(this.redisMap.curPrice, this.redisMap.costPrice);
            //   profitLossRate = math.chu(price, this.redisMap.costPrice, 4, 2);
            // } else {
            //   var price = math.jian(this.redisMap.costPrice, this.redisMap.curPrice);
            //   profitLossRate = math.chu(price, this.redisMap.costPrice, 4, 2);
            // }
            // profitLossRate = math.cheng(profitLossRate, '100', 2);
            // this.redisMap.profitLossRate = profitLossRate;

            //委托买卖
            var buyLists = this.redisMap.unfinish_buy_orders.orders;
            var buyList = [];
            buyLists.forEach((item)=>{
              item.source!='manual' && buyList.push(item);
            });
            this.buyList = buyList;

            var sellLists = this.redisMap.unfinish_sell_orders.orders;
            var sellList = [];
            sellLists.forEach((item)=>{
              item.source!='manual' && sellList.push(item);
            });
            this.sellList = sellList;

            this.buyPrice1 = this.buyList.length ? this.buyList[0].price : undefined;
            this.sellPrice1 = this.sellList.length ? this.sellList[0].price : undefined;
            this.pair.last = '0'; //由于拿的是交易对内的行情价，所以不准确，直接设置为0
            this.pairStr = JSON.stringify(this.pair);

            this.initMenu();
          } else {
            modal.toast(data.msg);
          }
        }
      );
    },

    //http一键平仓
    httpClosePosition() {
      if (this.executeId == '') {
        return;
      }

      modal.showLoad();
      var param = { 'executeId': this.executeId};
      weexHttp.postX("manualStrategy/closePosition",param,true,(data) => {

          modal.hideLoad();
          if (data.status == 200) {
            modal.toast(T('平仓成功'));
            this.httpExecuteDetail();
          } else {
            modal.toast(data.msg);
          }
        }
      );
    },

    /********************************** GET*/
    //获得策略状态字符
    getStateStr(states) {
      if (states == "EXECUTE") {
        return T("执行中");
      }

      if (states == "SUSPEND") {
        return T("已暂停");
      }

      if (states == "STARTING") {
        return T("启动中");
      }

      if (states == "STOPING") {
        return T("正在终止");
      }
    },

    //获交易所名称
    getExchangeName(){
      var remark = this.detailMap.remark && this.detailMap.remark.length ? ('·' + this.detailMap.remark) : '';
      return this.pair.apiName + remark + '（' + this.pair.counterCoin + '/' + this.pair.baseCoin + '）';
    },

    //时间转换(年月日时分)
    parseTime1(timestamp) {
      var time = new Date(Number(timestamp));

      var year = time.getFullYear();

      var month = time.getMonth() + 1;
      month = month < 10 ? "0" + month : month;

      var day = time.getDate();
      day = day < 10 ? "0" + day : day;

      var hour = time.getHours();
      hour = hour < 10 ? "0" + hour : hour;

      var minute = time.getMinutes();
      minute = minute < 10 ? "0" + minute : minute;

      return year + "/" + month + "/" + day + " " + hour + ":" + minute;
    },

    //获取执行时长
    getExecuteTime(startTime) {
      var time = new Date().getTime();
      var disTime = time - startTime;
      var day = Math.floor(disTime / 86400000);
      var hour = Math.floor((disTime % 86400000) / 3600000);
      var min = Math.floor(((disTime % 86400000) % 3600000) / 60000);
      return day + T("天") + hour + T("时") + min + T("分");
    },

    /********************************** 点击*/
    //隐藏
    hideClick(){
      if (this.detailMap == undefined){
        return;
      }
      this.showMenu = false;
    },

    //菜单点击
    menuClick(item){
      this.hideClick();

      if (item == '消息') {

        navigator.open(T('策略消息'), 'strategy/StrategyNotice', {stId:this.executeId});
        return;
      }
      
      if (item == '成交记录') {
        var param = {'executeId':this.executeId,
                    'counterCoin':this.redisMap.counterCoin,
                    'baseCoin':this.redisMap.baseCoin};
        navigator.openNative('tradeRecord',param);
        return;
      }

      var states = this.detailMap.states;
      if (states == "STARTING" || states == "STOPING" ) {
        modal.toast('请勿频繁操作');
        return;
      }
      
      if (item == '暂停') {

        amStrategy2.httpStip(this.executeId, false, ()=>{
          modal.toast(T('暂停成功'));
          broadcast.send(broadcast.EXECUTE_UPDATE);
        });
        return;
      }

      if (item == '终止') {
        
        var isMany = (item.executeType == 'FATHER');
        var param = {'cancelOrder':this.configMap.cancelOrder,
                    'isConvert':this.configMap.isConvert};
        navigator.openDialog('run/RunStop', param);

        broadcast.subscribeOnce('RunStop', (map)=>{

          var pair = this.configMap.tradePairs[0];
          var apiId = pair.apiId;
          var param = {'executeId':this.executeId, 
                      'apiId':apiId, 
                      'cancelOrder':map.cancelOrder, 
                      'isConvert':map.isConvert,
                      'isMany':false};
          amStrategy2.httpEnd(param,()=>{
            navigator.back();
            broadcast.send(broadcast.EXECUTE_UPDATE);
          });
        });
        return;
      }

      if (item == '重启') {
        amStrategy2.showServers(false, this.pair.api, (server)=>{
          var param = {'executeId':this.executeId};
          if (server) {
            param['serverCode'] = server.serverCode;
          }
          amStrategy2.restart(param, ()=>{
            modal.toast(T('重启成功'));
            broadcast.send(broadcast.EXECUTE_UPDATE);
          });
        });
        return;
      }
      
      if (item == '加仓') {
        
        
        var limitMap = this.detailMap.isFollow ? this.detailMap.followInvestLimit : this.followMap;

        var pair = this.configMap.tradePairs[0];
        var apiId = pair.apiId;
        var apiName = pair.apiName;
        amStrategy2.checkApi(apiId, apiName, (api)=>{
          var param = {'api':api,
                      'executeId':this.executeId, 
                      'states':this.detailMap.states,
                      'configMap':this.configMap,
                      'limitMap':limitMap};
          navigator.open('', 'run/RunAddInvest',param);
        });
        return;
      }
      
      if (item == '参数') {
        
        var param = {'executeId':this.executeId, 
                    'strategyName':this.detailMap.followName ? this.detailMap.followName : this.detailMap.strategyName,
                    'states':this.detailMap.states,
                    
                    'configMap':this.configMap,
                    'signalStates':this.detailMap.signalStates,
                    'followMap':this.followMap,
                    'isOpenFollow':this.detailMap.isOpenFollow,
                    'followMimic':this.followMimic};
        navigator.open('', 'run/RunParam',param);
        return;
      }
      
      if (item == '网格列表') {

        var param = {'executeId':this.executeId};
        navigator.open('', 'run/GridList',param);
        return;
      }

      if(item == '手动开仓') {

        //暂停、参数
        var zycwms = false;
        this.configMap.reserves.forEach((item)=>{
          if (item.name == '止盈仓位模式' && item.value == 1) {
            zycwms = true;
          }
        })
        var param = {'executeId':this.executeId, 'state':this.detailMap.states, zycwms};
        weexFunction.debugLog(param);
        navigator.open('', 'run/RunOp', param);
      }

      if(item == '一键平仓'){

        var parm = {title:T("一键平仓"),
                    message:T("确认平仓后，现有仓位将按照市价执行卖出操作，但策略不会终止，继续等待新的执行信号。"),
                    okBtn:T("确认"), cancelBtn:T("取消")};
        modal.confirm(parm, (bool)=>{
          if (bool == "true") {
            this.httpClosePosition(item);
          } else {

          }
        });
      }
    },

    //用户点击
    userClick(userId){
      var param = {'userId':userId};
      navigator.open('', "follw/UFollwManInfo",param);
    },
  },
};
</script>

 
<style src="@/_css/style.css"></style>
<style scoped>
.bg {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 9;
}
.scroller {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 9;
}
.wrapper {
  width: 750px;
  padding: 44px;
}
.msg {
  width: 28px;
  height: 28px;
  margin-right: 6px;
}
.line {
  margin-top: 40px;
  width: 710px;
  height: 2px;
  margin-bottom: 40px;
}
.line2 {
  margin-top: 40px;
  width: 710px;
  height: 2px;
  margin-bottom: 20px;
}
.floatText{
  line-height: 40px;
}
.text-right{
  text-align: right;
}
.text68{
  height: 68px;
  line-height: 68px;
}
.image{
  width: 56px;
  height: 56px;
  margin-right: 40px;
}
.arrow{
  width: 20px;
  height: 20px;
}

.buySell{
  width: 670px;
  height: 100px;
}

/*走势图*/
.line-chart {
  margin-top: 40px;
  flex: 1;
  height: 450px;
}
.line-chart-color{
  width: 20px;
  height: 12px;
  border-radius: 2px;
  
  margin-right: 20px;
}

/*********************************** 菜单*/
.menu{
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 9;
}
.meun-content {
  position: absolute;
  width: 204px;
  border-radius: 4px;
  
  padding-top: 20px;
  padding-bottom: 20px;

  top: 0;
  right: 0;
}
.meun-text {
  height: 80px;
  line-height: 80px;
  width: 204px;
  text-align: center;
}

/*********************************** 高度*/
.height20 {
  height: 20px;
}
.height40 {
  height: 40px;
}
.all2 {
  flex: 2;
}
.all3 {
  flex: 3;
}

.tips {
  align-items: center;
  justify-content: center;

  height: 44px;
  margin-top: -44px;
  margin-left: -44px;
  margin-right: -44px;
  margin-bottom: 20px;
}
</style>
